home *** CD-ROM | disk | FTP | other *** search
- /* KNB Version 2.0 */
- //code gen'd by Case:W 4.0
- #define EXTERN
- #include "TSTCTL.hpp"
-
- #include <commdlg.h>
-
- #include <uty25001.h>
- #include <uty3dowl.h>
-
-
- _CLASSDEF(TMyAppObject);
- class _EXPORT TMyAppObject : public TApplication
- {
-
- public:
- /* Application object constructor. */
- TMyAppObject(
- LPSTR AppName,
- HINSTANCE hCurr,
- HINSTANCE hPrev,
- LPSTR CmdLine,
- int CmdShow) :TApplication(AppName,hCurr,hPrev,CmdLine,CmdShow){};
-
- virtual void InitMainWindow();
- virtual void InitApplication()
- {
- UtyCtlMakeLink();
- };
- BOOL ProcessMDIAccels(LPMSG) { return FALSE; };
-
- };
-
- /*************************************************************************/
- /* */
- /* Class Definition For Window Object tstctlTWindow */
- /* */
- /*************************************************************************/
-
- _CLASSDEF(tstctlTWindow);
-
- class _EXPORT tstctlTWindow : public TWindow
- {
- private:
- PTListBox pList;
- public:
- /* Derived window constructor */
- tstctlTWindow(PTWindowsObject AParent, LPSTR ATitle);
- void SetupWindow();
- virtual void GetWindowClass(WNDCLASS _FAR &AWndClass);
- virtual Pchar nameOf() const { return "tstctlTWindow"; }
- virtual LPSTR GetClassName() { return (LPSTR)"tstctlTWindow" ; };
- virtual void CMMethod_IDM_DIALOG(RTMessage Msg) =
- [CM_FIRST + IDM_DIALOG];
- void CwCreateClientControls(PTWindowsObject);
- void WMCtlColor(RTMessage msg)
- = [WM_FIRST + WM_CTLCOLOR];
- };
-
-
-
- /************************************************************************/
- /* */
- /* Class definition for testTDialog Object. */
- /* */
- /************************************************************************/
-
- _CLASSDEF(testTDialog);
-
- class _EXPORT testTDialog : public TDialog
- {
- private:
-
- public:
- testTDialog(PTWindowsObject Parent, int ResID);
- virtual void SetupWindow();
- virtual Pchar nameOf() const { return "testTDialog"; }
- void Ok(RTMessage Msg) =
- [ID_FIRST + IDOK];
- void FileOpen(RTMessage Msg) =
- [ID_FIRST + 131];
- };
-
-
- /*************************************************************************/
- /* */
- /* WinMain, the main of the OWL program */
- /* */
- /* In an OWL program, WinMain does very little actual work. The appli- */
- /* cation object takes responsibility for most of the tasks formerly */
- /* carried out by WinMain. */
- /* WinMain is one of the few functions in an OWL program that had to be */
- /* modified for STRICT compliance. Instance handles (hCurrent and hPrev)*/
- /* were of type HANDLE in Windows 3.0, but are now of type HINSTANCE. */
- /* */
- /*************************************************************************/
-
- int PASCAL WinMain(HINSTANCE hCurrent,
- HINSTANCE hPrev,
- LPSTR Cmdline,
- int CmdShow)
- {
-
- /* Instantiate the application object derived from OWL TApplication
- object */
- TMyAppObject MyApplication("Test New Controls",
- hCurrent,
- hPrev,
- Cmdline,
- CmdShow);
-
- /* Start the message queue and display the main Window object */
- /* This invokes the InitInstance() method of the Application object
- * which calls the InitMainWindow() method to create the main window
- * and calls the Show() method of the main window to display it. */
-
-
- MyApplication.Run();
-
- return(MyApplication.Status);
-
- }
-
- /*************************************************************************/
- /* */
- /* Member fuctions for the TMyAppObject class, a descendent of the */
- /* OWL TApplication class. Each OWL program has a single application */
- /* object that handles instance initialization and cleanup, and drives */
- /* the program's message loop. */
- /* */
- /*************************************************************************/
-
- /*--------------------------------------------------------------------*/
- /* TMyAppObject::InitMainWindow member function */
- /* The InitMainWindow function is called by the application's Run() */
- /* member function. It creates the application's main window object */
- /*--------------------------------------------------------------------*/
-
- void TMyAppObject::InitMainWindow()
- {
- /* Instantiate a new Window object derived from OWLs TWindow object
- and save the handle in the MainWindow data member of the Application
- object */
-
- MainWindow = new tstctlTWindow(
- NULL, /* No parent */
- "Test New Controls");
-
- }
-
-
- /*************************************************************************/
- /* */
- /* Member functions of the Window object: tstctlTWindow */
- /* */
- /* The tstctlTWindow object is the main window for the */
- /* application. */
- /* */
- /*************************************************************************/
-
- /*--------------------------------------------------------------------*/
- /* tstctlTWindow object Constructor */
- /* The constructor is called by C++ whenever an object is created */
- /* It handles initialization of the object. */
- /*--------------------------------------------------------------------*/
-
- tstctlTWindow::tstctlTWindow(
- PTWindowsObject AParent, LPSTR ATitle)
- : TWindow(AParent, ATitle) /* Base Constructor */
- {
- /* Set the creation attributes for the Window Object */
- Attr.Style =
- WS_SYSMENU | /* Add system menu box */
- WS_MINIMIZEBOX | /* Add minimize box */
- WS_MAXIMIZEBOX | /* Add maximize box */
- WS_THICKFRAME | /* thick sizeable frame */
- WS_CAPTION;
- /* Set the Menu attribute of the Window Object. */
- AssignMenu("TSTCTL");
- /* Create a device independant size and location */
- long nWndunits = GetDialogBaseUnits();
- int nWndx = LOWORD(nWndunits);
- int nWndy = HIWORD(nWndunits);
- int nX = ((5 * nWndx) / 4);
- int nY = ((34 * nWndy) / 8);
- int nWidth = ((206 * nWndx) / 4);
- int nHeight = ((163 * nWndy) / 8);
-
- /* Set the size and location of the window object */
- Attr.X = nX;
- Attr.Y = nY;
- Attr.W = nWidth;
- Attr.H = nHeight;
-
- //add child controls
- //new TUty3DEdit(this, 101, "Edit me", 20, 20, 110, 40, 0, FALSE);
-
- CwCreateClientControls(this);
-
- EnableKBHandler();
- }
-
- /*--------------------------------------------------------------------*/
- /* GetWindowClass() member function */
- /* */
- /* This method is called before the window class is registered. It */
- /* should set any parameters in the WNDCLASS structure that apply to */
- /* the tstctlTWindow class */
- /*--------------------------------------------------------------------*/
-
- void tstctlTWindow::GetWindowClass(WNDCLASS _FAR &AWndClass)
- {
-
- /* Call the default method to create WNDCLASS structure with defaults*/
- TWindow::GetWindowClass(AWndClass);
-
- /* Set Registration specific attributes here. */
-
- AWndClass.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
- };
-
- /*-------------------------------------------------------------------*/
- /* SetupWindow() member function */
- /* This method is called after the interface element is created. OWL */
- /* invokes it from its WM_CREATE message response member function. */
- /*-------------------------------------------------------------------*/
-
- void tstctlTWindow::SetupWindow()
- {
-
- /* Call the default */
- TWindow::SetupWindow();
-
- pList->AddString("Item 1");
- pList->AddString("Item 2");
- pList->AddString("Item 3");
- pList->AddString("Item 4");
- pList->AddString("Item 5");
- pList->AddString("Item 6");
- pList->AddString("Item 7");
- pList->AddString("Item 8");
- pList->AddString("Item 9");
- }
-
- /*--------------------------------------------------------------------*/
- /* CMMethod_IDM_DIALOG() command response member function */
- /* Called when the user selects the IDM_DIALOG */
- /* menu item */
- /*--------------------------------------------------------------------*/
-
- void tstctlTWindow:: CMMethod_IDM_DIALOG(RTMessage Msg)
- {
-
- /* Execute the Modal Dialog: testTDialog Object. */
- GetModule()->ExecDialog(
- new testTDialog(this, IDLG_TEST));
- UNREFERENCED_PARAMETER(Msg);
- }
-
- void tstctlTWindow::WMCtlColor(RTMessage msg)
- {
- HBRUSH hbrush;
-
- hbrush = UtyCtlWMCtlColor(msg.Message,
- msg.WParam,
- msg.LParam);
-
- if (hbrush != (HBRUSH)FALSE)
- msg.Result = (LRESULT)hbrush;
- else
- DefWndProc(msg);
-
-
- }
-
- /*******************************************************************
- Function: CwCreateClientControls(
-
- Description:
-
- ********************************************************************/
-
- void tstctlTWindow::CwCreateClientControls(PTWindowsObject parent)
- {
- int nCyscroll; /* Height of the scroll Arrow */
- long DlgUnits; /* Structure to store Dialog units*/
-
- #define DlgToWinX(x) ((x * LOWORD(DlgUnits)) / 4) /* x modulo */
- #define DlgToWinY(y) ((y * HIWORD(DlgUnits)) / 8) /* y modulo */
- nCyscroll = 0;
-
- /* Get the dialog units by querying the system */
- DlgUnits = GetDialogBaseUnits();
-
- /* Create all the Controls as children */
- PTWindow control;
-
- control =
- new TUty3DStatic(parent, -1,
- "Test Controls with SUTY3D.DLL",
- DlgToWinX(46), /* x position */
- DlgToWinY(4)+nCyscroll, /* y position */
- DlgToWinX(108), /* width */
- DlgToWinY(8), /* height */
- 80);
-
- //control->Attr.Style |=
- // SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP;
-
-
- pList =
- new TUty3DListBox(parent, 101,
- DlgToWinX(8), /* x position */
- DlgToWinY(26)+nCyscroll, /* y position */
- DlgToWinX(49), /* width */
- DlgToWinY(33)); /* height */
-
- //pList->Attr.Style |=
- // LBS_NOTIFY | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL;
-
-
- control =
- new TUty3DComboBox(parent, 102,
- DlgToWinX(66), /* x position */
- DlgToWinY(26)+nCyscroll, /* y position */
- DlgToWinX(31), /* width */
- DlgToWinY(33), /* height */
- CBS_SIMPLE, 80);
-
- control->Attr.Style |=
- CBS_SIMPLE | WS_CHILD | WS_VISIBLE | WS_TABSTOP;
-
-
- control =
- new TUty3DComboBox(parent, 103,
- DlgToWinX(106), /* x position */
- DlgToWinY(26)+nCyscroll, /* y position */
- DlgToWinX(30), /* width */
- DlgToWinY(33), /* height */
- CBS_DROPDOWN, 80);
-
- control->Attr.Style |=
- CBS_DROPDOWN | WS_CHILD | WS_VISIBLE | WS_TABSTOP;
-
-
- control =
- new TUty3DComboBox(parent, 104,
- DlgToWinX(145), /* x position */
- DlgToWinY(26)+nCyscroll, /* y position */
- DlgToWinX(36), /* width */
- DlgToWinY(33), /* height */
- CBS_DROPDOWN, 80);
-
- control->Attr.Style |=
- CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_TABSTOP;
-
-
- control =
- new TUty3DGroupBox(parent, 105,
- "Check Boxes",
- DlgToWinX(7), /* x position */
- DlgToWinY(70)+nCyscroll, /* y position */
- DlgToWinX(75), /* width */
- DlgToWinY(42), /* height */
- NULL);
-
- //control->Attr.Style |=
- // BS_GROUPBOX | WS_CHILD | WS_VISIBLE;
-
-
- control =
- new TUty3DCheckBox(parent, 106,
- "Text",
- DlgToWinX(20), /* x position */
- DlgToWinY(83)+nCyscroll, /* y position */
- DlgToWinX(28), /* width */
- DlgToWinY(12), /* height */
- NULL);
-
-
- //control->Attr.Style |=
- // BS_CHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP;
-
-
- control =
- new TUty3DCheckBox(parent, 107,
- "Text",
- DlgToWinX(20), /* x position */
- DlgToWinY(96)+nCyscroll, /* y position */
- DlgToWinX(28), /* width */
- DlgToWinY(12), /* height */
- NULL);
-
- //control->Attr.Style |=
- // BS_CHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP;
-
-
- control =
- new TUty3DGroupBox(parent, 108,
- "Radios",
- DlgToWinX(94), /* x position */
- DlgToWinY(70)+nCyscroll, /* y position */
- DlgToWinX(75), /* width */
- DlgToWinY(42), /* height */
- NULL);
-
- //control->Attr.Style |=
- // BS_GROUPBOX | WS_CHILD | WS_VISIBLE;
-
-
- control =
- new TUty3DRadioButton(parent, 109,
- "Radio",
- DlgToWinX(105), /* x position */
- DlgToWinY(81)+nCyscroll, /* y position */
- DlgToWinX(28), /* width */
- DlgToWinY(12), /* height */
- NULL);
-
-
- //control->Attr.Style |=
- // BS_RADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP;
-
-
- control =
- new TUty3DRadioButton(parent, 110,
- "Radio",
- DlgToWinX(105), /* x position */
- DlgToWinY(96)+nCyscroll, /* y position */
- DlgToWinX(28), /* width */
- DlgToWinY(12), /* height */
- NULL);
-
-
- //control->Attr.Style |=
- // BS_RADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP;
-
- };
-
-
-
-
- /*************************************************************************/
- /* */
- /* Member functions For Dialog object testTDialog */
- /* */
- /* The Dialog object displays a modal or modeless dialog box. */
- /*************************************************************************/
-
- /* Constructor */
- testTDialog::testTDialog(
- PTWindowsObject AParent, int ResourceID)
- : TDialog(AParent, ResourceID) /* Parent Constructor */
- {
- }
-
- /*--------------------------------------------------------------------*/
- /* SetupWindow method for the testTDialog */
- /* */
- /* Called after the dialog's window is created, but before it is */
- /* displayed. This is similar to the TWindow's SetupWindow method */
- /* but is called in response to the WM_INITDIALOG message. */
- /*--------------------------------------------------------------------*/
-
- void testTDialog::SetupWindow()
- {
- /* Let the default processing be done */
- /* Any special processing that has to be done on the control object
- has to be done here. */
- TDialog::SetupWindow();
-
- /* Center the Dialog On the Client Area of the Parent. */
- /*
- RECT swp, rParent;
- POINT pt;
- GetWindowRect(HWindow, &swp);
- GetClientRect(Parent->HWindow, &rParent);
- int nWidth = swp.right - swp.left;
- int nHeight = swp.bottom - swp.top;
- pt.x = (rParent.right - rParent.left) / 2;
- pt.y = (rParent.bottom - rParent.top) / 2;
- ClientToScreen(Parent->HWindow, &pt);
- pt.x = pt.x - (nWidth / 2);
- pt.y = pt.y - (nHeight / 2);
- MoveWindow(HWindow, pt.x, pt.y, nWidth, nHeight, FALSE);
- */
- }
-
-
- /*--------------------------------------------------------------------*/
- /* Ok() - command response member function. */
- /* */
- /* Called when the user presses the "OK" button. */
- /*--------------------------------------------------------------------*/
- void testTDialog::Ok(RTMessage Msg)
- {
- switch (Msg.LP.Hi)
- {
- case BN_CLICKED:
- Destroy(TRUE);
-
- break;
- }
- }
-
- void testTDialog::FileOpen(RTMessage Msg)
- {
- switch (Msg.LP.Hi)
- {
- case BN_CLICKED:
- {
-
- OPENFILENAME ofnTemp;
- DWORD Errval; // Error value
- char buf[5]; // Error buffer
- char Errstr[50]="GetOpenFileName returned Error #";
-
-
- char szName[256];
- char szTemp[] = "All Files (*.*)\0*.*\0Text Files (*.txt)\0*.txt\0";
- *szName = '\0';
- ofnTemp.lStructSize = sizeof( OPENFILENAME );
- ofnTemp.hwndOwner = HWindow;
- ofnTemp.hInstance = UtyCtlGetInstance(); //get instance of the dll for the template
- ofnTemp.lpstrFilter = (LPSTR)szTemp;
- ofnTemp.lpstrCustomFilter = NULL;
- ofnTemp.nMaxCustFilter = 0;
- ofnTemp.nFilterIndex = 1;
- ofnTemp.lpstrFile = (LPSTR)szName;
- ofnTemp.nMaxFile = sizeof( szName );
- ofnTemp.lpstrFileTitle = NULL;
- ofnTemp.nMaxFileTitle = 0;
- ofnTemp.lpstrInitialDir = NULL;
- ofnTemp.lpstrTitle = "3D OpenFile";
- ofnTemp.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY
- | OFN_PATHMUSTEXIST |OFN_ENABLETEMPLATE;
- //turn on template flag
- ofnTemp.nFileOffset = 0;
- ofnTemp.nFileExtension = 0;
- ofnTemp.lpstrDefExt = "*";
- ofnTemp.lCustData = NULL;
- ofnTemp.lpfnHook = NULL;
- ofnTemp.lpTemplateName = UtyCtlGetTemplate(UTY3DTEMP_OPENSAVE);
- //gives the tempate name in the 3d dll
- //see uty25001.h for other #defines
-
- if(GetOpenFileName( &ofnTemp ) != TRUE)
- {
- Errval=CommDlgExtendedError();
- if(Errval!=0) // 0 value means user selected Cancel
- {
- sprintf(buf,"%ld",Errval);
- strcat(Errstr,buf);
- MessageBox(HWindow,Errstr,"WARNING",MB_OK|MB_ICONSTOP);
- }
-
- }
-
- }
-
- }
-
- }
-
-
-
-